import {Button, Flex, Form, Input, message} from "antd";
import {useState} from "react";
import {expertAdd, IExpert} from "@/api/expert.ts";

interface IProps {
    cancel: () => void
    ok: () => void
}

const ExpertForm = ({ cancel, ok }: IProps) => {
    const [initValues] = useState({})
    const onFinish = async (values: IExpert) => {
        const response = await expertAdd(values)
        if (response.code === 200) {
            ok()
            message.success('操作成功')
        } else {
            message.error('操作失败')
        }
    }
    return (
        <Form labelCol={{ span: 4 }} wrapperCol={{ span: 20 }} style={{ maxWidth: 600 }} initialValues={initValues} onFinish={onFinish} autoComplete="off">
            <Form.Item<IExpert> name="expertName" label='主播名称'>
                <Input />
            </Form.Item>
            <Form.Item<IExpert> name="expertID" label='主播ID'>
                <Input />
            </Form.Item>
            <Form.Item<IExpert> rules={[{ required: true, message: '请填写主播微信' }]} name="expertWx" label='主播微信'>
                <Input />
            </Form.Item>
            <Form.Item<IExpert> name="expertSendSample" label='寄样'>
                <Input />
            </Form.Item>
            <Form.Item<IExpert> name="expertAddress" label='地址'>
                <Input />
            </Form.Item>
            <Form.Item<IExpert> name="expertCode" label='单号'>
                <Input />
            </Form.Item>

            <Form.Item label={null}>
                <Flex gap={'middle'} justify={'end'}>
                    <Button onClick={cancel}>取消</Button>
                    <Button type="primary" htmlType="submit">提交</Button>
                </Flex>
            </Form.Item>
        </Form>
    )
}

export default ExpertForm